<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
    <meta content="telephone=no" name="format-detection"/>
    <meta content="email=no" name="format-detection"/>
    <title>去开团</title>
    <script type="text/javascript" src="/Template/js/jquery.1.11.1.js"></script>
    <script type="text/javascript" src="/Template/js/vue.min.js"></script>
    <script type="text/javascript" src="/Template/js/common.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript" charset="utf-8"></script>

    <link rel="stylesheet" type="text/css" href="/Template/css/weui.min.css">
    <link rel="stylesheet" type="text/css" href="/Template/css/common.css">

    <script>
        $(document).ready(function () {

            var wsServer = 'ws://114.215.113.76:9502';
            var websocket = new WebSocket(wsServer);

            websocket.onopen = function (evt) {
                console.log("Connected");
            };

            websocket.onclose = function (evt) {
                console.log("Disconnected");
            };

            websocket.onmessage = function (evt) {
                console.log(evt);
                var data = JSON.parse(evt.data);

                if($(".user-pay").length > 0) {

                    var endTime = null;
                    var ua = navigator.userAgent.toLowerCase();
                    if (/iphone|ipad|ipod/.test(ua)) {
                        endTime = safariDate(data.create_time);
                    } else if (/android/.test(ua)) {
                        endTime = new Date(data.create_time.replace(/-/g,","));
                    }
                    var timeGap = getTimeGap2(endTime, new Date(), "seconds");

                    $(".user-pay-content .user-img").attr("style","background: url('"+data.headimgurl+"')no-repeat center;background-size: cover;");
                    $(".user-pay-content .user-name").html(data.nickname);
                    $(".user-pay-content .pay-time").html(timeGap["seconds"]+"秒");

                    $(".user-pay").addClass("active");

                    setTimeout(function() {
                        $(".user-pay").removeClass("active");
                    },2000);
                }
            };

            websocket.onerror = function (evt, e) {
                console.log('Error occurred: ' + evt.data);
            };

        });
    </script>
</head>
<body id="container">